package com.neusmart.tongrentang.model;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * Topic Photo
 * <p/>
 * roy
 */
public class Photo implements Parcelable {

    public Photo() {
        //
    }

    public Photo(String url) {
        this.url = url;
    }

    public Photo(UploadNotify notify) {
        this.url = notify.getUrl();
        this.fileUploadId = notify.getFileUploadId();
        this.imgWidth = notify.getImgWidth();
        this.imgHeight = notify.getImgHeight();
    }

    //
    private String url;
    //
    private String fileUploadId;
    //
    private int imgWidth;
    //
    private int imgHeight;
    //
    private String created;

    protected Photo(Parcel in) {
        url = in.readString();
        fileUploadId = in.readString();
        imgWidth = in.readInt();
        imgHeight = in.readInt();
        created = in.readString();
    }

    public static final Creator<Photo> CREATOR = new Creator<Photo>() {
        @Override
        public Photo createFromParcel(Parcel in) {
            return new Photo(in);
        }

        @Override
        public Photo[] newArray(int size) {
            return new Photo[size];
        }
    };

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getFileUploadId() {
        return fileUploadId;
    }

    public void setFileUploadId(String fileUploadId) {
        this.fileUploadId = fileUploadId;
    }

    public int getImgWidth() {
        return imgWidth;
    }

    public void setImgWidth(int imgWidth) {
        this.imgWidth = imgWidth;
    }

    public int getImgHeight() {
        return imgHeight;
    }

    public void setImgHeight(int imgHeight) {
        this.imgHeight = imgHeight;
    }

    public String getCreated() {
        return created;
    }

    public void setCreated(String created) {
        this.created = created;
    }

    public double getRatio() {
        return imgHeight * 1.00 / imgWidth;
    }

    public String getThumbnailUrl() {
        return url + "@300h_300w_1e_1c";
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(url);
        dest.writeString(fileUploadId);
        dest.writeInt(imgWidth);
        dest.writeInt(imgHeight);
        dest.writeString(created);
    }
}
